from selenium import webdriver
import re
from parsel import Selector

brower = webdriver.Chrome()
brower.get('http://www.porters.vip/captcha/jigsaw.html')
jigsawCircle = brower.find_element_by_id('jigsawCircle')
action = webdriver.ActionChains(brower)
action.click_and_hold(jigsawCircle).perform()
html = brower.page_source
sel = Selector(html)
missblock = sel.css('#missblock::attr("style")').get()
targetblock = sel.css('#targetblock::attr("style")').get()
extract = lambda x:''.join(re.findall('left: (\d+|\d+.\d+)px',x))
mbk_left = extract(missblock)
tbk_left = extract(targetblock)
distance = float(tbk_left) - float(mbk_left)
action.move_by_offset(distance,0)
action.release().perform()


